package cn.com.yang.thread;

import java.util.concurrent.CountDownLatch;

/**
 * 线程计数器2 TODO
 * 
 * @author yangyijin
 * @since 2023年10月24日-上午9:46:38
 */
public class TestCountDownLatch2 {
	public static void main(String[] args) throws InterruptedException {
		CountDownLatch latch = new CountDownLatch(10);
		Runnable runnable = new Runnable() {
			@Override
			public void run() {
				System.out.println(Thread.currentThread().getName());
				latch.countDown();
			}
		};
		for (int i = 0; i < 10; i++) {
			Thread t = new Thread(runnable);
			t.start();
		}
		latch.await();
		System.out.println("10个线程比赛结束");
	}
}
